function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

var t = Object.assign || function(e) {
    for (var t = 1; t < arguments.length; t++) {
        var a = arguments[t];
        for (var s in a) Object.prototype.hasOwnProperty.call(a, s) && (e[s] = a[s]);
    }
    return e;
}, a = e(require("../../../api/api.js")), s = e(require("../../../utils/util.js")), i = e(require("../../../utils/filter.js")), n = require("../../../config/constants.js"), o = require("../../../data/translate.js"), r = e(require("../../../utils/wxParse/wxParse")), d = e(require("./parser")), u = getApp();

Page({
    data: {
        session_type: "all",
        package_type: "all",
        session_problem_type: "problem_all",
        session_type_index: 0,
        package_type_index: 0,
        session_problem_type_index: 0,
        activeIndex: 0,
        sliderOffset: 0,
        sliderLeft: 0,
        noScroll: !1,
        isFromPayPage: !1
    },
    onLoad: function(e) {
        var t = this;
        s.default.wxInterceptor(), t.data.session_id = e.id, t.setData({
            session_detail_type: e.type,
            session_detail_page_id: e.id
        }), "package" === e.type ? (wx.setNavigationBarTitle({
            title: "课时包详情"
        }), t.getPackageDetail(e.id)) : "session" === e.type || "trial" === e.type ? t.getSessionDetail(e.id) : (wx.setNavigationBarTitle({
            title: "问题课时详情"
        }), t.getSessionProblemDetail(e.id));
    },
    onShow: function() {
        var e = getCurrentPages();
        5 === parseInt(e.length) && this.setData({
            isFromPayPage: !0
        });
    },
    onUnload: function() {
        var e = getCurrentPages();
        if (parseInt(e.length) >= 4 && (u.globalData.isCharged = !0, wx.switchTab({
            url: "../sessions"
        })), "session" === this.data.session_detail_type && 0 !== this.data.session_detail_datum.package_id) {
            var t = getCurrentPages();
            t[t.length - 2].onLoad({
                id: this.data.session_detail_datum.package_id,
                type: "package"
            });
        }
    },
    getSessionDetail: function(e) {
        var t = this, s = wx.getStorageSync("token") || "", i = {
            i_token: s
        };
        a.default.sessionDetail({
            data: i,
            token: s,
            session_id: e,
            success: function(a) {
                if (a && a.data.data) {
                    var s = a.data.data, i = s.student_textid;
                    t.mergeSessionInfo(s), t.setData({
                        session_detail_datum: s,
                        student_textid: i,
                        curentTeacherId: s.teacher_id
                    }), t.getOperateHistory(e), t.getMessage(e);
                } else a && a.data.redirect && wx.navigateTo({
                    url: "/pages/sessions/detail/detail?id=" + a.data.redirect.data + "&type=" + a.data.redirect.page
                });
            }
        });
    },
    mergeSessionInfo: function(e) {
        e.course_title = i.default.sessionCourseTitle(e), e.learn_language_cn = i.default.convertSymbolToText(e.learn_language, o.LANGUAGE_DATUM) || e.learn_language, 
        e.user_type && (e.focus_user_is_teacher = 2 === e.user_type);
        var t = i.default.convertSessionStatus(e);
        e.status_desc = t || "canceled", e.user_avatar_file = n.CDN_ADDR + e.oppo_user_obj.avatar_file_name + "_Avatar.jpg", 
        e.start_time_formated = {
            date: s.default.getSpecificDayByDate(e.session_start_time_user),
            time: s.default.getSpecificHourByDate(e.session_start_time_user),
            week: s.default.getWeekByDate(e.session_start_time_user)
        }, e.actionList = d.default.parseLessonActionHTML(e.op_html), r.default.wxParse("status_body", "html", e.status_body, this), 
        e.session_status_desc = i.default.convertSessionStatusDesc(e), e.session_price_dollar = (e.session_price_usd / 100).toFixed(2), 
        e.session_price_cny = i.default.convertCurrencyToCNY(e.session_price_usd, u.globalData.currencyDatum), 
        e.current_user_name = u.globalData.userPersonalInfo.nickname;
    },
    getOperateHistory: function(e) {
        var t = this, s = wx.getStorageSync("token") || "", i = {
            i_token: s
        };
        a.default.sessionOperateHistory({
            data: i,
            token: s,
            session_id: e,
            success: function(e) {
                if (e && e.data.data) {
                    var a = e.data.data;
                    a.forEach(t.mergeOperateHistory), t.setData({
                        session_operate_datum: a
                    });
                }
            }
        });
    },
    mergeOperateHistory: function(e, t, a) {
        e.time_formated = {
            date: s.default.getSpecificDayByDate(e.create_time_user),
            time: s.default.getSpecificHourByDate(e.create_time_user)
        }, e.history_desc = i.default.sessionOperationDesc(this.data.session_detail_datum, e, t, a);
    },
    getPackageDetail: function(e) {
        var t = this, s = wx.getStorageSync("token") || "", i = {
            i_token: s
        };
        a.default.sessionPackageDetail({
            data: i,
            package_id: e,
            token: s,
            success: function(a) {
                if (a && a.data.data) {
                    var s = a.data.data, i = s.student_textid;
                    t.mergePackageInfo(s), t.setData({
                        package_detail_datum: s,
                        student_textid: i,
                        curentTeacherId: s.teacher_id
                    }), t.getMessage(e);
                }
            }
        });
    },
    mergePackageInfo: function(e) {
        var t = e.valid_session_obj_s;
        t.forEach(this.mergeValidSession), e.validList = t;
        var a = [], s = e.user_type, c = e.status, l = e.invalid_session_obj_s;
        l.forEach(this.mergeInvalidSession), e.invalidList = l, e.newRequestCount = 0;
        var _ = e.sessions_total;
        if (e.notScheduledCount = _ - t.length || "0", 1 == s && "5" == c) {
            for (var m = 0; m < e.notScheduledCount; m++) {
                var p = {
                    _id: "-1"
                };
                a.push(p);
            }
            e.addList = a;
        }
        e.scheduledCount = t.length - 0, e.canCancelPackage = "5" == e.status, e.learn_language_cn = i.default.convertSymbolToText(e.learn_language, o.LANGUAGE_DATUM) || e.learn_language, 
        e.course_title = i.default.sessionCourseTitle(e), e.actionList = d.default.parsePackageActionHTML(e.op_html), 
        r.default.wxParse("status_body", "html", e.status_body, this), e.package_status_desc = i.default.convertPackageStatusDesc(e), 
        e.user_avatar_file = n.CDN_ADDR + e.oppo_user_obj.avatar_file_name + "_Avatar.jpg", 
        e.session_price_dollar = (e.package_price_usd / 100).toFixed(2), e.session_price_cny = i.default.convertCurrencyToCNY(e.package_price_usd, u.globalData.currencyDatum), 
        "0" === e.status || "3" === e.status || "B" === e.status || "6" === e.status || "C" === e.status || "5" === e.status ? e.status_desc = "activity" : e.status_desc = "canceled";
    },
    mergeValidSession: function(e) {
        "0" == e.status && e.newRequestCount++, [ "7", "C", "H" ].indexOf(e.status) > -1 && (e.hasNeedActionLesson = !0), 
        e.session_start_hour = s.default.getSpecificHourByDate(e.session_start_time_user), 
        e.session_start_day = s.default.getSpecificDayByDate(e.session_start_time_user);
    },
    mergeInvalidSession: function(e) {
        e.session_start_hour = s.default.getSpecificHourByDate(e.session_start_time_user), 
        e.session_start_day = s.default.getSpecificDayByDate(e.session_start_time_user);
    },
    getSessionProblemDetail: function(e) {
        var s = this, i = {
            i_token: wx.getStorageSync("token") || ""
        };
        a.default.sessionProblemDetail({
            data: i,
            session_id: e,
            success: function(a) {
                if (a && a.data.data) {
                    var i = a.data.data, n = a.data.meta.session_obj;
                    s.mergeSessionProblem(n);
                    for (var o = [], r = a.data.data.length, d = 0; d < r; d++) {
                        var u = a.data.data[d];
                        s.makeProblemContent(u, n), "" != u.content && (s.makeProblemUser(u, n), s.makeProblemLabel(u), 
                        u.hasDemand && (s.makeProblemDemand(u, n), s.makeProblemReason(u)), o.push(u));
                    }
                    var c = a.data.meta.session_obj.student_textid;
                    s.makeSessionLabel(n), s.makeSessionNavi(n), s.makeSessionDescription(o, n), s.setData(t({}, s.state, {
                        session_problem_detail_datum: i,
                        session_problem_detail_meta: n,
                        problemList: o,
                        student_textid: c
                    })), s.getMessage(e);
                }
            }
        });
    },
    mergeSessionProblem: function(e) {
        "C" === e.status || "S" === e.status || "O" === e.status || "H" === e.status ? e.status_desc = "waiting" : e.status_desc = "canceled", 
        e.course_title = i.default.sessionCourseTitle(e), e.start_time_formated = {
            date: s.default.getSpecificDayByDate(e.session_start_time_user),
            time: s.default.getSpecificHourByDate(e.session_start_time_user),
            week: s.default.getWeekByDate(e.session_start_time_user)
        }, e.learn_language_cn = i.default.convertSymbolToText(e.learn_language, o.LANGUAGE_DATUM) || e.learn_language, 
        e.session_status_desc = i.default.convertSessionProblemStatusDesc(e), e.user_avatar_file = n.CDN_ADDR + e.oppo_user_obj.avatar_file_name + "_Avatar.jpg", 
        e.session_price_dollar = (e.session_price_usd / 100).toFixed(2), e.session_price_cny = i.default.convertCurrencyToCNY(e.session_price_usd, u.globalData.currencyDatum);
    },
    makeProblemUser: function(e, t) {
        e.operater == t.user_type ? e.operater_obj = u.globalData.userPersonalInfo : 1 == e.operater || 2 == e.operater ? e.operater_obj = t.oppo_user_obj : e.operater_obj = {
            id: 0,
            avatar_file_name: "T000000000"
        };
    },
    makeProblemLabel: function(e) {
        var t, a;
        switch (e.operater) {
          case 1:
            t = "label-student", a = "学生";
            break;

          case 2:
            t = "label-teacher", a = "教师";
            break;

          default:
            t = "label-italki", a = "ITALKI";
        }
        e.labelCss = t, e.labelName = a;
    },
    makeProblemReason: function(e) {
        switch (e.problem_reason) {
          case 1:
            e.reason = "学生没有出席该课时";
            break;

          case 2:
            e.reason = "教师没有出席该课时";
            break;

          default:
            e.reason = "其他";
        }
    },
    makeProblemDemand: function(e, t) {
        var a = "";
        a = "2" == t.session_type ? e.itc_usd > 0 ? "视该课时为正常完成。" : "视该课时为未完成。在该课时包中补偿一个课时。" : "S" == e.status ? "重新安排該課時" : 0 == e.itc_usd ? "退还所有信用点数给学生" : e.itc_usd == t.session_price_usd ? "将课时信用点数转给教师" : "退还$" + (t.session_price_usd - e.itc_usd) / 100 + "USD信用点数给学生，将 $" + e.itc_usd / 100 + "USD信用点数转给教师。 ", 
        e.demand = a;
    },
    makeProblemContent: function(e, t) {
        if ("7" == e.prev_status && [ "C", "S", "H", "E", "P" ].indexOf(e.status) > -1) return e.operater == t.user_type ? e.content = "您指出该课时存在问题。" : e.content = 2 == t.user_type ? "学生指出该课时存在问题。" : "该课时应该完成了。教师指出该课时存在问题。", 
        void (e.hasDemand = !0);
        var a = "";
        switch (e.status) {
          case "H":
            a = 2 == t.user_type ? 2 == e.operater ? "您已拒绝学生的请求。" : "学生已拒绝您的请求。" : 2 == e.operater ? "教师已拒绝您的请求。" : "您已拒绝教师的请求。";
            break;

          case "Q":
            ("S" == e.prev_status || "H" == e.prev_status) && [ 1, 2 ].indexOf(e.operater) > -1 && (a = 2 == t.user_type ? 2 == e.operater ? "您已经接受学生提出的重新安排课时的请求。课时问题已经解决。" : "学生已经接受您提出的重新安排课时的请求。" : 2 == e.operater ? "教师已经接受您提出的重新安排课时的请求。课时问题已经解决。" : "您已经接受教师提出的重新安排课时的请求。");
            break;

          case "P":
            9 == e.operater || 10 == e.operater ? a = "课时问题已经被解决。 一个额外的课时已经被添加至课时包内。" : (a = 2 == t.user_type ? "您已接受学生的请求。" : "教师已接受您的请求。", 
            a += "课时问题已经被解决。 一个额外的课时已经被添加至课时包内。");
            break;

          case "E":
            if ("2" == t.session_type) {
                a = 2 == t.user_type ? 1 == e.operater ? "学生已接受您的请求。" : "" : 1 == e.operater ? "您已接受教师的请求。" : "", 
                a += "课时状态已更改为完成。";
                break;
            }
            if ("Q" == e.prev_status || "O" == e.prev_status) {
                a = "问题已解决: ", e.itc_usd > 0 && (a = "$" + e.itc_usd / 100 + "USD信用点数已转给教师"), t.problem_refund_usd > 0 && (a = "$" + e.itc_usd / 100 + "USD信用点数已转给学生。"), 
                a += "What Is Dispute Resolution And How Does Italki Handle This?";
                break;
            }
            if (2 == t.user_type) switch (e.operater) {
              case 1:
                a = "学生已接受您的请求。", 0 == t.problem_refund_usd ? a += "该课时信用点数已转入您的帐户。" : t.session_price_usd == t.problem_refund_usd ? a += "该课时全额费用已转入学生的帐户。" : a = "$" + e.itc_usd / 100 + "USD信用点数已转入您的账户,$" + t.problem_refund_usd / 100 + "USD信用点数已转入学生的账户。";
                break;

              case 2:
                a = "您已接受学生的请求。", 0 == t.problem_refund_usd ? a += "该课时信用点数已转入您的帐户。" : t.session_price_usd == t.problem_refund_usd ? a += "该课时全额费用已转入学生的帐户。" : a = "$" + t.problem_refund_usd / 100 + "USD信用点数已转入学生的账户，$" + e.itc_usd / 100 + "USD信用点数已转入您的账户。";
                break;

              default:
                a = 0 == t.problem_refund_usd ? "该问题已解决。课时信用点数已转到您的账户。" : t.session_price_usd == t.problem_refund_usd ? "该问题已解决。课时信用点数已退回至学生的账户。" : "$" + t.problem_refund_usd / 100 + "USD信用点数已转入学生的账户，$" + e.itc_usd / 100 + "USD信用点数已转入您的账户。";
            } else switch (e.operater) {
              case 1:
                a = "您已接受教师的请求。", 0 == t.problem_refund_usd ? a += "该课时信用点数已转入教师的帐户。" : t.session_price_usd == t.problem_refund_usd ? a += "该课时信用点数已转入教师的帐户。" : a += "$" + e.itc_usd / 100 + "USD信用点数已转入教师的账户，$" + t.problem_refund_usd / 100 + "USD信用点数已转入您的账户。";
                break;

              case 2:
                a = "教师已接受您的请求。", 0 == t.problem_refund_usd ? a += "该课时信用点数已转入教师的帐户。" : t.session_price_usd == t.problem_refund_usd ? a += "该课时全额费用已转入您的帐户。" : a = "$" + t.problem_refund_usd / 100 + "USD信用点数已转入您的账户，$" + e.itc_usd / 100 + "USD信用点数已转入教师的账户。";
                break;

              default:
                a = 0 == t.problem_refund_usd ? "该问题已解决。课时信用点数已转到教师的账户。" : t.session_price_usd == t.problem_refund_usd ? "该问题已解决。课时信用点数已退回至您的账户。" : "$" + t.problem_refund_usd / 100 + "USD信用点数已转入您的账户，$" + e.itc_usd / 100 + "USD信用点数已转入教师的账户。";
            }
        }
        e.content = a, e.hasDemand = !1;
    },
    makeSessionLabel: function(e) {
        var t, a;
        switch (e.status) {
          case "C":
          case "S":
          case "O":
            e.operater == e.user_type ? (t = "wait", a = "等待") : (t = "action", a = "需要操作");
            break;

          case "H":
            t = "action", a = "争议";
            break;

          default:
            t = "resolve", a = "已解决";
        }
        e.label = {
            css: t,
            text: a
        };
    },
    makeSessionNavi: function(e) {
        var t = 0, a = "";
        switch (e.status) {
          case "C":
          case "S":
            e.operater != e.user_type && (a = "请在" + (e.update_time + 518400) + e.current_time + "内响应");

          case "H":
          case "Q":
          case "Q":
          case "W":
            t = 2;
            break;

          case "P":
          case "E":
            t = 3;
        }
        e.navi = {
            step: t,
            alert: a
        };
    },
    makeSessionDescription: function(e, t) {
        var a = "", i = "", n = [], o = [];
        switch (t.status) {
          case "C":
          case "S":
            var r = s.default.getDate(t.update_time).setDate(s.default.getDate(t.update_time).getDate() + 6), d = new Date(Date.parse(t.current_time)).getTime(), u = s.default.getDate(t.current_time).getTime(), c = new Date(t.update_time_user).setDate(new Date(t.update_time_user).getDate() + 6), l = s.default.getDate(t.update_time_user);
            l.setDate(l.getDate() + 6);
            var _ = s.default.transformSessionDiffDate(l), m = Math.floor(Math.abs(r - u) / 1e3 / 60 / 60 / 24), p = s.default.timestampToTime(c);
            if (t.operater == t.user_type) {
                t.operater, a = "请等待对方响应。", a += "将会在" + m + "天内作出决定[" + _ + "], 如果对方没有响应，则您的请求将默认为成功。";
                break;
            }
            i = "C" == t.status ? "E" : "Q", a = "请在" + r + d + " 内响应 [于" + p + " 前]。", 1 == t.operater ? (n.push("学生的请求将被接受"), 
            "S" == t.status ? n.push("可以安排一个新课时。您可以选择一个新的日期与时间。") : "2" == t.session_type ? n.push("可以安排一個新課時。您可以選擇一個新的日期與時間。") : 0 == t.problem_refund_usd ? n.push("该课时信用点数将会转到您的账户") : t.problem_refund_usd == t.session_price_usd ? n.push("该课时信用点数将会退回至学生账户") : n.push("$" + (t.problem_refund_usd, 
            2) + "USD信用点数将退回学生的账户，$" + (t.session_price_usd - t.problem_refund_usd) / 100, 2), 
            o.push("学生的请求将被拒绝"), a += "如果您在规定时间内未响应,，系统将默认您同意学生的称陈述和要求。") : (n.push("教师的请求将被接受"), 
            "S" == t.status ? n.push("可以安排一个新课时。您可以选择一个新的日期与时间。") : "2" == t.session_type ? n.push(" 该课时将被视为成功完成。") : 0 == t.problem_refund_usd ? n.push("该课时信用点数将会转到教师的账户") : t.problem_refund_usd == t.session_price_usd ? n.push("该课时信用点数将会转到您的账户") : (n.push("$" + (t.session_price_usd - t.problem_refund_usd) / 100, 2), 
            t.problem_refund_usd), o.push("教师的请求将被拒绝"), a += "如果您在规定时间内未响应，系统将默认您同意教师的陈述和要求。"), 
            o.push("该课时当前处于争议中。italki 将联系双方并作出最终裁决。");
            break;

          case "H":
            a = "该课时当前处于争议中。italki 将联系双方并作出最终裁决。";
            break;

          case "Q":
            a = "课时问题已经被解决。 一个额外的课时已经被添加至课时包内。重新预约课时";
            break;

          case "E":
            [ 1, 2 ].indexOf(t.operater) > -1 && "7" == e[e.length - 1].prev_status && (a = "2" == t.session_type ? "课时状态已更改为完成。" : 1 == t.operater ? "该课时时间已过。$" + t.session_price_usd / 100 + "美元信用点数已转入教师的账户。" : "该课时时间已过。$" + t.session_price_usd / 100 + "美元信用点数已转入学生的账户。");
            break;

          case "p":
            2 == t.operater && "7" == e[e.length - 1].prev_status && (a = "课时问题已经被解决。 一个额外的课时已经被添加至课时包内。");
        }
        t.Desc = a, t.next_status = i, t.acceptDesc = n, t.declineDesc = o;
    },
    getMessage: function(e) {
        var s = this, i = wx.getStorageSync("token") || "", n = {
            i_token: i
        };
        if ("package" === this.data.session_detail_type) o = "package/"; else var o = "";
        a.default.getMessage({
            data: n,
            token: i,
            session_id: e,
            session_type: o,
            success: function(e) {
                if (e && e.data.data) {
                    var a = e.data.data;
                    a.forEach(s.getComment_time), a.forEach(s.isStudentSend), s.setData(t({}, s.state, {
                        session_message_datum: a
                    }));
                }
            }
        });
    },
    getComment_time: function(e) {
        e.comment_time = s.default.convertUTCTimeToLocalTime(e.create_time).slice(-5);
    },
    isStudentSend: function(e) {
        e.isStudent;
        this.data.student_textid === e.sender_textid ? e.isStudent = !0 : e.isStudent = !1;
    },
    mergeMessageInfo: function(e) {
        e.comment_time = s.default.getSpecificHourByDate(e.create_time);
    },
    sendMessage: function(e) {
        var t = this;
        if (this.data.session_problem_detail_meta) s = "1" == this.data.session_problem_detail_meta.user_type; else if (this.data.package_detail_datum) s = "1" == this.data.package_detail_datum.user_type; else var s = "1" == this.data.session_detail_datum.user_type;
        var i = {
            content: e.detail.value.textarea,
            create_time: new Date().getTime(),
            isStudent: s
        }, n = wx.getStorageSync("token") || "", o = this.data.session_detail_page_id;
        if ("package" === this.data.session_detail_type) r = "package/"; else var r = "";
        a.default.sendMessage({
            method: "POST",
            data: i,
            token: n,
            session_id: o,
            session_type: r,
            success: function(e) {
                e && e.data.data && (t.getMessage(o), t.setData({
                    session_msg: ""
                }));
            }
        });
    },
    doAction: function(e) {
        var t = this, s = e.currentTarget.dataset.name.session_id, i = wx.getStorageSync("token") || "", n = {
            next_status: e.currentTarget.dataset.statusType,
            status: e.currentTarget.dataset.name.status,
            update_time: e.currentTarget.dataset.name.update_time
        };
        a.default.sessionDetail({
            method: "POST",
            data: n,
            session_id: s,
            token: i,
            success: function(e) {
                e && e.data.data && t.onLoad({
                    id: s,
                    type: "session"
                });
            }
        });
    },
    onLessonAction: function(e) {
        var t = this, a = e.currentTarget.dataset.statusType, s = e.currentTarget.dataset.name.package_id;
        if ("1" === a) wx.showModal({
            title: "取消课时",
            success: function(a) {
                a.confirm ? t.doAction(e) : a.cancel && console.log("用户点击取消");
            }
        }); else if ("4" === a || "5_N" === a) wx.showModal({
            title: "拒绝",
            success: function(a) {
                a.confirm ? t.doAction(e) : a.cancel && console.log("用户点击拒绝");
            }
        }); else if ("9" === a) {
            wx.setNavigationBarTitle({
                title: "取消课时"
            }), this.cancelSession = this.selectComponent("#cancelSessionModal");
            var i = e.currentTarget.dataset.name, n = e.currentTarget.dataset.statusType;
            this.setData({
                sessionInfo: i,
                nextStatus: n
            }), this.cancelSession.show();
        } else if ("3_itc" === a) {
            wx.setNavigationBarTitle({
                title: "更改价格"
            }), this.updateItcModal = this.selectComponent("#updateItcModal");
            var o = e.currentTarget.dataset.name, r = e.currentTarget.dataset.statusType;
            this.setData({
                sessionInfo: o,
                nextStatus: r
            }), this.updateItcModal.show();
        } else if ("5" === a || "3_time" === a || "O" === a) {
            this.calendarModal = this.selectComponent("#calendarModal");
            var d = e.currentTarget.dataset.name, u = e.currentTarget.dataset.statusType;
            this.setData({
                sessionInfo: d,
                nextStatus: u
            }), this.getTeacherAvailableTime(d.teacher_id), this.calendarModal.show();
        } else if ("6_cannot_change_time" === a) {
            var c = this.data.session_detail_datum.teacher_im_account;
            wx.showModal({
                content: "如果你希望通过移动设备进行课程，还请下载第三方教学软件（如Skype）, Skype | ID：" + c,
                success: function(e) {
                    e.confirm ? console.log("确定") : e.cancel && console.log("取消");
                }
            });
        } else if ("6" === a || "5_Y" === a || "X" === a) wx.showModal({
            title: "确认操作",
            success: function(a) {
                a.confirm ? t.doAction(e) : a.cancel && console.log("用户点击接受");
            }
        }); else if ("F" === a) wx.setNavigationBarTitle({
            title: "确认课时"
        }), this.confirmModal = this.selectComponent("#confirmModal"), this.getTeacherFeedback(e), 
        this.confirmModal.show(); else if ("C" === a) if (wx.setNavigationBarTitle({
            title: "课时问题"
        }), 0 !== s) {
            this.packageProblemModal = this.selectComponent("#packageProblemModal");
            var l = e.currentTarget.dataset.name;
            this.setData({
                sessionInfo: l
            }), this.packageProblemModal.show(this.data.session_problem_detail_datum);
        } else {
            this.problemModal = this.selectComponent("#problemModal");
            var _ = e.currentTarget.dataset.name;
            this.setData({
                sessionInfo: _
            }), this.problemModal.show(this.data.session_problem_detail_datum);
        } else if ("G" === a) {
            wx.setNavigationBarTitle({
                title: "发表评价"
            }), this.feedbackModal = this.selectComponent("#feedbackModal");
            var m = e.currentTarget.dataset.name, p = e.currentTarget.dataset.statusType;
            this.setData({
                sessionInfo: m,
                nextStatus: p
            }), this.feedbackModal.show();
        } else if ("RESOLVE" === a) {
            var f = e.currentTarget.dataset.name;
            wx.navigateTo({
                url: "../detail/detail?id=" + f.id + "&type=session_problem"
            });
        } else wx.showModal({
            title: "更多操作",
            content: "更多操作请通过其他客户端进行修改",
            success: function(e) {
                e.confirm ? console.log("确定") : e.cancel && console.log("取消");
            }
        });
    },
    doPackageAction: function(e) {
        var t = this, s = e.currentTarget.dataset.name.id, i = wx.getStorageSync("token") || "", n = {
            next_status: e.currentTarget.dataset.statusType,
            status: e.currentTarget.dataset.name.status,
            update_time: e.currentTarget.dataset.name.update_time
        };
        a.default.sessionPackageDetail({
            method: "POST",
            data: n,
            package_id: s,
            token: i,
            success: function(e) {
                e && e.data.data && t.onLoad({
                    id: s,
                    type: "package"
                });
            }
        });
    },
    onPackageAction: function(e) {
        var t = this, a = e.currentTarget.dataset.statusType;
        "1" === a || "5" === a || "4" === a ? wx.showModal({
            title: "确认操作",
            success: function(a) {
                a.confirm ? t.doPackageAction(e) : a.cancel && console.log("课时包状态调整");
            }
        }) : "7" === a ? wx.showModal({
            title: "接受",
            success: function(a) {
                a.confirm ? t.doPackageAction(e) : a.cancel && console.log("用户点击接受");
            }
        }) : "Z" === a ? wx.showModal({
            title: "拒绝",
            success: function(a) {
                a.confirm ? t.doPackageAction(e) : a.cancel && console.log("用户点击拒绝");
            }
        }) : wx.showModal({
            title: "更多操作",
            content: "更多操作请通过其他客户端进行修改",
            success: function(e) {
                e.confirm ? console.log("确定") : e.cancel && console.log("取消");
            }
        });
    },
    toggleSessionDay: function(e) {
        this.setData({
            activeDayAvailableTime: e.detail.activeDayAvailableTime,
            activeDayIndex: e.detail.activeDayIndex,
            activeHourIndex: e.detail.activeHourIndex
        });
    },
    selectSessionTime: function(e) {
        this.setData({
            activeHourIndex: e.detail.activeHourIndex,
            activeDayAvailableTime: e.detail.activeDayAvailableTime,
            bookSectionTime: e.detail.bookSectionTime
        });
    },
    selectRateStar: function(e) {
        this.setData(t({}, this.data, {
            activeStar: e.detail.activeStar
        }));
    },
    selectBasicTag: function(e) {
        this.data.tag_id_list = e.detail.tag_id_list, this.data.feedbackDatum.public_basic_tag_list.forEach(this.dynamicBasicTagClass), 
        this.setData(t({}, this.data, {
            feedbackDatum: this.data.feedbackDatum
        }));
    },
    dynamicBasicTagClass: function(e) {
        -1 !== this.data.tag_id_list.indexOf(e.tag_id) && (e.tag_class = "green-btn");
    },
    getTeacherFeedback: function(e) {
        var t = this, s = this.data.session_detail_datum.id, i = wx.getStorageSync("token") || "";
        a.default.teacherFeedback({
            session_id: s,
            token: i,
            success: function(a) {
                if (a && a.data.data) {
                    var s = a.data.data, i = e.currentTarget.dataset.name, n = e.currentTarget.dataset.statusType;
                    t.mergeFeedbackInfo(s), t.setData({
                        sessionInfo: i,
                        nextStatus: n,
                        feedbackDatum: s
                    });
                }
            }
        });
    },
    mergeFeedbackInfo: function(e) {
        e.teacher_avatar_file = n.CDN_ADDR + e.teacher_info.avatar_file_name + "_Avatar.jpg", 
        e.public_basic_tag_list.forEach(this.convertBasicTagToText);
    },
    convertBasicTagToText: function(e) {
        1 === e.tag_id ? e.tag_text = "准时" : 2 === e.tag_id ? e.tag_text = "准备充分" : e.tag_text = "有帮助的";
    },
    updateItcOperate: function(e) {
        var t = this, s = wx.getStorageSync("token") || "", i = this.data.session_detail_datum.id, n = {
            next_status: this.data.nextStatus,
            status: this.data.session_detail_datum.status,
            update_time: this.data.session_detail_datum.update_time,
            itc_new_usd: e.detail.itc_new_usd
        };
        a.default.sessionDetail({
            method: "POST",
            data: n,
            session_id: i,
            token: s,
            success: function(e) {
                e && e.data.data && t.onLoad({
                    id: i,
                    type: "session"
                });
            }
        });
    },
    cancelSessionOperate: function(e) {
        var t = this, s = wx.getStorageSync("token") || "", i = this.data.session_detail_datum.id, n = {
            next_status: this.data.nextStatus,
            status: this.data.session_detail_datum.status,
            update_time: this.data.session_detail_datum.update_time,
            problem_reason: e.detail.problem_reason,
            problem_msg: e.detail.problem_msg
        };
        a.default.sessionDetail({
            method: "POST",
            data: n,
            session_id: i,
            token: s,
            success: function(e) {
                e && e.data.data && t.onLoad({
                    id: i,
                    type: "session"
                });
            }
        });
    },
    feedbackOperate: function(e) {
        var t = this, s = wx.getStorageSync("token") || "", i = this.data.session_detail_datum.id, n = {
            next_status: this.data.nextStatus,
            status: this.data.session_detail_datum.status,
            update_time: this.data.session_detail_datum.update_time,
            comment: e.detail.feedback
        };
        a.default.sessionDetail({
            method: "POST",
            data: n,
            session_id: i,
            token: s,
            success: function(e) {
                e && e.data.data && t.onLoad({
                    id: i,
                    type: "session"
                });
            }
        });
    },
    checkConfirmOperate: function(e) {
        var t = this, s = wx.getStorageSync("token") || "", i = this.data.session_detail_datum.id, n = {
            next_status: this.data.nextStatus,
            status: this.data.session_detail_datum.status,
            update_time: this.data.session_detail_datum.update_time,
            score: e.detail.score,
            comment: e.detail.comment,
            public_basic_vote_tag_id_list: e.detail.public_basic_vote_tag_id_list
        };
        a.default.sessionDetail({
            method: "POST",
            data: n,
            session_id: i,
            token: s,
            success: function(e) {
                e && e.data.data && t.onLoad({
                    id: i,
                    type: "session"
                });
            }
        });
    },
    problemConfirmOperate: function(e) {
        var t = wx.getStorageSync("token") || "", s = this.data.session_detail_datum.id, i = {
            status: this.data.session_detail_datum.status,
            update_time: this.data.session_detail_datum.update_time,
            problem_msg: e.detail.problem_msg,
            next_status: e.detail.next_status,
            problem_reason: e.detail.problem_reason,
            refund_itc_usd: e.detail.refund_itc_usd
        };
        a.default.sessionDetail({
            method: "POST",
            data: i,
            session_id: s,
            token: t,
            success: function(e) {
                e && e.data.data && wx.navigateTo({
                    url: "../detail/detail?id=" + s + "&type=session_problem"
                });
            }
        });
    },
    addSessionOperate: function(e) {
        var t = this, s = wx.getStorageSync("token") || "", i = this.data.package_detail_datum.id, n = {
            time: this.data.bookSectionTime
        };
        a.default.packageAddSession({
            method: "POST",
            data: n,
            package_id: i,
            token: s,
            success: function(e) {
                e && e.data.data && t.onLoad({
                    id: i,
                    type: "package"
                });
            }
        });
    },
    confirmOperate: function(e) {
        var t = this, s = wx.getStorageSync("token") || "", i = this.data.session_detail_datum.id, n = {
            next_status: this.data.nextStatus,
            status: this.data.session_detail_datum.status,
            update_time: this.data.session_detail_datum.update_time,
            session_time_new: this.data.bookSectionTime
        };
        a.default.sessionDetail({
            method: "POST",
            data: n,
            session_id: i,
            token: s,
            success: function(e) {
                e && e.data.data && t.onLoad({
                    id: i,
                    type: "session"
                });
            }
        });
    },
    getTeacherAvailableTime: function(e) {
        var t = this, i = wx.getStorageSync("token") || "", n = {
            start_time: s.default.getDateStr(1) + " 00:00",
            end_time: s.default.getDateStr(4) + " 23:59",
            i_token: i
        };
        a.default.getTeacherAvailableTime({
            query: {
                id: e
            },
            data: n,
            success: function(e) {
                if (e && e.data.data) {
                    var a = e.data.data.slice(0, 4);
                    a.map(function(e) {
                        e.calendar_day = s.default.formatCurrentDate(e.day).substring(5), e.week_day = s.default.getWeekByDate(e.day);
                    }), t.setData({
                        availableTimeDatum: a,
                        activeDayAvailableTime: a[0]
                    });
                }
            }
        });
    },
    scheduleNewSession: function(e) {
        this.calendarModal = this.selectComponent("#calendarModal");
        var t = e.currentTarget.dataset.name;
        this.getTeacherAvailableTime(t.teacher_id), this.calendarModal.show();
    },
    bindToSessionDetail: function(e) {
        var t = e.currentTarget.dataset.name, a = t.session_id || t.id;
        wx.navigateTo({
            url: "../detail/detail?id=" + a + "&type=session"
        });
    },
    onReady: function() {
        this.calendarModal = this.selectComponent("#calendarModal");
    },
    bindToTeacherProfile: function(e) {
        var t = e.currentTarget.dataset.teacherId;
        wx.navigateTo({
            url: "../../../pages/teacher/profile/profile?id=" + t
        });
    },
    onImageError: function(e) {
        var t = this;
        s.default.errImgFun(e, t);
    },
    noScrollOperate: function(e) {
        this.setData({
            noScroll: e.detail.noScroll
        });
    }
});